package cn.rongdao.jrkabao.ui.main.tab

import android.content.Context
import android.support.annotation.DrawableRes
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import cn.rongdao.jrkabao.constant.SPConstant
import com.mifengkong.frtools.util.FRSharedPreferences
import com.mifengkong.frtools.util.FRString
import kotlinx.android.synthetic.main.layout_main_tab.view.*

/**
 * Created by jack on 2017/12/18
 */

class TabUIComponent : RelativeLayout {


    constructor(context: Context) : super(context)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

    constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)


    fun setTabContent(content: String) {
        lmt_tv_title.text = FRString.valueOf(content)
    }

    fun setActivityVisible() {
        val corner = FRSharedPreferences.getStringNotClear(SPConstant.ALL_OTHER_LOAN_CORNER, "")
        if (!FRString.isEmpty(corner)) {
            lmt_tv_activity.visibility = View.VISIBLE
            lmt_tv_activity.text = corner
        } else {
            lmt_tv_activity.visibility = View.GONE
        }
    }

    fun setImageView(@DrawableRes drawableRes: Int) {
        lmt_iv_imageView.setBackgroundResource(drawableRes)
    }

    fun setTabSelected(isSelected: Boolean) {
        lmt_iv_imageView.isSelected = isSelected
        lmt_tv_title.isSelected = isSelected
    }
}
